package day14;

import java.util.*;

//import static HomeWork.Bank;

public class HomeWork {
}

class A3{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        LinkedList<String> list = new LinkedList<>();
        //先进先出
        while(true){
            System.out.println("选择:1.输入 2.输出 3.取消");
            int choice = sc.nextInt();
            if(choice==3){
                return;
            }
            else if(choice==1){
                System.out.println("请输入需要添加的字符串:");
                String str = sc.next();
                list.add(str);
                System.out.println("添加成功");
            }
            else if(choice==2){
                System.out.println("成功删除:"+list.getFirst());
                list.removeFirst();
            }
        }
    }
}

class B3{
    public static void main(String[] args) {
        Random rand = new Random();
        List<Bank> list = new ArrayList<>();
        HashMap<String,Integer> set = new HashMap<>();
        //int count = 0;
        for(int i=0; i<100; i++){
        double money = rand.nextDouble(10000)+500;
        String name = "" + (char)(rand.nextInt(26)+97);
        list.add(new Bank(name,money));
        }
        for(Bank b : list){
            if(set.containsKey(b.name)){
                set.put(b.name, set.get(b.name)+1);
            }
            else {
                set.put(b.name,0);
            }
        }
        int maxValue = 0;
        String maxName = null;
        for (Map.Entry<String, Integer> entry : set.entrySet()) {
            if (entry.getValue() > maxValue) {
                maxValue = entry.getValue();
                maxName = entry.getKey();
            }
        }
        double money = 0;
        for(Bank b : list){
            if(b.name.equals(maxName)){
                if(b.money>money){
                    money = b.money;
                }
            }
        }
        System.out.println("消费次数最多的人:"+maxName);
        System.out.println("最高消费："+(int)money +"元");
    }
}

class Bank{
    String name;
    double money;
    public Bank(String name,double money){
        this.name=name;
        this.money=money;
    }
}

class A4{
    public static void main(String[] args) {
        Set<Integer> set=new TreeSet<>();
        Set<Integer> set2=new TreeSet<>();
        Scanner sc = new Scanner(System.in);
        Random rand = new Random();
        while(set.size()<6){
            set.add(rand.nextInt(33)+1);
        }
        int SetBlue = rand.nextInt(16)+1;
        System.out.println("红球:"+set);
        System.out.println("篮球:"+SetBlue);
        System.out.println("请输入一个红球编号(共计6个，且不可重复)");
        int n = 0,num;
        while(n<6){
            num = sc.nextInt();
            if(num<1 || num>33){
                System.out.println("输入错误，请重新输入！！！");
            }
            else {
                if(set2.contains(num)){
                    System.out.println("输入错误，请重新输入！！！");
                }
                else {
                set2.add(num);
                n++;
                }
            }
        }
        System.out.println("输入完成");
        System.out.println(set2);
        int MyBlue;
        System.out.println("请输入蓝球的编号:");
        while (true){
            num = sc.nextInt();
            if(num<1 || num>16){
                System.out.println("输入错误，请重新输入！！！");
            }
            else {
                MyBlue = num;
                break;
            }
        }
        set.retainAll(set2);
        int number = set.size();
        boolean BlueSz=false;
        if(MyBlue==SetBlue){
            BlueSz = true;
        }
        switch (number){
            case 3:System.out.println("六等奖,您获得10元");break;
            case 4:
                if(BlueSz){
                System.out.println("四等奖，您获得200元");}
                else {
                    System.out.println("五等奖，您获得50元");
                }
                break;
            case 5:
                if(BlueSz){
                System.out.println("二等奖，您获得5000元");}
                else {
                System.out.println("三等奖，您获得500元");
                }
                break;
            case 6:
                if(BlueSz){
                    System.out.println("一等奖，您获得100000元");}
                else {
                    System.out.println("二等奖，您获得5000元");
                }
                break;
            default:System.out.println("您未获奖");break;
        }
    }
}

class B4{
    public static void main(String[] args) throws InterruptedException {
        List<FightCard> sumlist = new ArrayList<>();
        String[] color = {"♣","♥","♠","♦"};
        String[] nums = {"3","4","5","6","7","8","9","10","J","Q","K","A","2"};
        Integer[] n = {3,4,5,6,7,8,9,10,11,12,13};
        for(String c:color){
            for(int i = 0;i<nums.length;i++ ){
                sumlist.add(new FightCard(c+nums[i],i+3));
            }
        }
        sumlist.add(new FightCard("大🃏",17));
        sumlist.add(new FightCard("小🃏",16));
        System.out.println(sumlist);
        //Thread.sleep(2000);
        Collections.shuffle(sumlist);
        System.out.println(sumlist);
        List<FightCard> farmer1 = new ArrayList<>();
        List<FightCard> farmer2 = new ArrayList<>();
        List<FightCard> landowner = new ArrayList<>();
        for(int i = 0;i<3;i++){
            landowner.add(sumlist.remove(0));
        }
        while(!sumlist.isEmpty()){
            farmer1.add(sumlist.remove(0));
            farmer2.add(sumlist.remove(0));
            landowner.add(sumlist.remove(0));
        }
        System.out.println("农民1"+farmer1);
        System.out.println("农民2"+farmer2);
        System.out.println("地主"+landowner);
        System.out.println("排序后");
        Comparator<FightCard> com=(o1,o2)->{
            int n1=o2.num-o1.num;
            if(n1==0) n1=o1.str.compareTo(o2.str);
            return n1;
        };
        Collections.sort(farmer1,com);
        Collections.sort(farmer2,com);
        Collections.sort(landowner,com);
        System.out.println("农民1:"+farmer1);
        System.out.println("农民2:"+farmer2);
        System.out.println("地主:"+landowner);
    }
}

class FightCard{
    String str;
    Integer num;
    public FightCard(String str,Integer num){
        this.str=str;
        this.num=num;
    }
    public String toString(){
        return str;
    }
}